package com.showdor.springboot;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author showdor
 * @email chuanqi@outlook.com
 * @date 2023/7/5
 */
@Component
public class SendKafkaToFirst {
    private final Logger logger = LoggerFactory.getLogger(PartitionConsumer.class);

    @Autowired
    KafkaTemplate kafkaTemplate;
    public static final String TOPIC = "first";

    //@Scheduled(cron = "0/1 * * * * ? *")
    public void sendKafka() {
        logger.info("---====定时任务执行了：向first发送条数据====---");
        for (int i = 1; i <= 100; i++) {
            kafkaTemplate.send(TOPIC, i + "====provider====");
            logger.info("---===" + i + "===---");
        }
    }
}
